home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / INIT - CDEV / INIT - CDEV.make < prev    next >
Encoding:
Text File  |  1991-01-15  |  11.5 KB  |  281 lines  |  [TEXT/MPS ]

  1. #------------------------------------------------------------------------------
  2. #
  3. #    Macintosh Developer Technical Support
  4. #
  5. #    Sample Control Panel Device and INIT Combination
  6. #
  7. #    Program:    INIT - CDEV
  8. #    File:        INIT - CDEV.make    -    Make Source
  9. #
  10. #    Copyright © 1990 Apple Computer, Inc.
  11. #    All rights reserved.
  12. #
  13. #------------------------------------------------------------------------------
  14.  
  15. AppName            =    'INIT - CDEV'
  16. Signature        =    'INCD'
  17.  
  18.  
  19. #------------------------------------------------------------------------------
  20. #
  21. # Options for our compilers:
  22. #
  23. #    -sym on:
  24. #        tells the compilers and linker to emit symbol information for
  25. #        a source level debugger, such as SADE.
  26. #
  27. #    -case on:
  28. #        tells the assembler to treat case differences in symbols as being
  29. #        siginificant. We turn this on because we are dealing with C source
  30. #        as well, which is also case-sensitive. If we were compiling with
  31. #        Pascal, we'd probably turn case off so that we could reference
  32. #        Pascal symbols without having to upper-case them all (which is how
  33. #        Pascal exports its symbols).
  34. #
  35. #    -r:
  36. #        Tells the C compiler to require function prototypes. If it encounters
  37. #        a function definition without first having seen a prototype for
  38. #        it, it will mark it as an error.
  39. #
  40. #    -b:
  41. #        Tells the C compiler to embed literal strings in the C code. Normally,
  42. #        string constants are stored in the global variables space and
  43. #        references off of A5. Since are writing standalone code that
  44. #        doesn't normally have an A5 globals space, we embed the strings into
  45. #        the code and reference it off of  the PC. There are ways of using
  46. #        globals in standalone code, and we use them in the INIT part of
  47. #        our show, but we don't in the CDEV, so we embed them.
  48. #
  49. #    -mbg off:
  50. #        tells the compilers to not emit low-level debugger names. This
  51. #        saves on file space, but you may wish to remove this option if you
  52. #        need to debug with something like Macsbug.
  53. #
  54. #    -append:
  55. #        means to add the resources to the target file, rather than
  56. #        deleting all the ones that are there first.
  57. #
  58. #    -msg nowarn:
  59. #        Tells the Linker to not print any warning messages. When we link
  60. #        our INIT and CDEV we link them with the same list of MPW libraries.
  61. #        However, both the INIT and CDEV need a different set of libraries,
  62. #        so we define the list of libraries to be the union of the needs of
  63. #        the INIT and CDEV. This means that when we link, the linker will
  64. #        tell us we are linking with some unnecessary libraries. Because we
  65. #        don't care about those warnings, we turn them off with this option.
  66. #
  67. #    -rt xxxx=####:
  68. #        This tells the Linker what resource type to create. Normally, it puts
  69. #        its output into CODE resources. Here, we tell it to put it into a
  70. #        cdev=-4064 resource or an INIT=0 resource.
  71. #
  72. #    -m <Procedure Name>:
  73. #        This tells the Linker what the main entry point of our program is. If
  74. #        you are using Pascal, this is normally the routine whose "END"
  75. #        statement is followed by a period. If we are using C, then a main
  76. #        routine is provided for us ("CMain" in CRuntime.o if using MPW 3.1,
  77. #        or "%__Main" in Runtime.o if using MPW 3.2). However, when building
  78. #        stand-alone code, we don't want to use those main procedures; they are
  79. #        for applications only. Therefore, we provide our own entry point for
  80. #        the Linker explicitly. When the Linker does its dead-code stripping, it
  81. #        starts with this routine and does a treewalk. For applications, the
  82. #        main entry point is given jump table location #1 so that the segment
  83. #        loader can find it. Also note that the routine's name needs to be
  84. #        all uppercased for Pascal routines.
  85. #
  86. #    -sg <Segment Name>:
  87. #        MPW only supports single segment standalone code. This means that
  88. #        all of your executable code must belong to one segment. The easiest
  89. #        way to make sure that all of your routines and libraries that they
  90. #        use are put into one segment is to use the -sg <Segment Name> option.
  91. #        Normally, you would say something like -sg <Segment Name>=<list of
  92. #        segments>, which would merge those segments in the list into a single
  93. #        segment with the name <Segment Name>. However, if you omit the list
  94. #        of segments, ALL of your procedures will get put into <Segment Name>.
  95. #
  96. #    -ra <Segment Name> = <attributes>:
  97. #        Sets the resource attributes for the named resource. When INITs are
  98. #        executed, they aren't locked by INIT 31. Because our INIT allocates
  99. #        memory when installing its patch, we must make sure we are locked 
  100. #        down. If not, the code that is executing could be moved out from 
  101. #        under the PC.
  102. #
  103. #------------------------------------------------------------------------------
  104.  
  105. SymOptions        =    #-sym on                    # turn this on to debug with SADE
  106.  
  107. AOptions        =    -case on {SymOptions}
  108. COptions        =    -r -b -mbg off -d SystemSevenOrLater=1 {SymOptions}
  109. RezOptions        =    -append
  110. LinkOptions        =    -msg nowarn {SymOptions}
  111. CDEVLinkOptions    =    {LinkOptions} -rt cdev=-4064 -m TEXTCDEV -sg theCDEV
  112. INITLinkOptions    =    {LinkOptions} -rt INIT=0 -m INITInstall -sg theINIT ∂
  113.                     -ra theINIT=resLocked
  114.  
  115.  
  116. #------------------------------------------------------------------------------
  117. # These are modified default build rules.  This is necessary to take into
  118. # account differences between MPW 3.1 and 3.2. The normal make rules include
  119. # everything below except that they don't have an {xAltOptions} variable.
  120. # We've added those variables to pass in flags that allow the source code
  121. # to use the appropriate symbols and definitions for the version of MPW
  122. # it's running under. We also add some snazzy echo statements that report
  123. # our progress.
  124. #------------------------------------------------------------------------------
  125.  
  126. .a.o            ƒ    .a
  127.     Echo "    Assembling:    {Default}.a"
  128.     {Asm} {DepDir}{Default}.a -o {TargDir}{Default}.a.o {AOptions} {AAltOptions}
  129.  
  130. .c.o            ƒ    .c
  131.     Echo "    Compiling:    {Default}.c"
  132.     {C} {DepDir}{Default}.c -o {TargDir}{Default}.c.o {COptions} {CAltOptions}
  133.  
  134. .p.o            ƒ    .p
  135.     Echo "    Compiling:    {Default}.p"
  136.     {Pascal} {DepDir}{Default}.p -o {TargDir}{Default}.p.o {POptions} {PAltOptions}
  137.  
  138.  
  139. #------------------------------------------------------------------------------
  140. # These are the lists of objects that our sample creates. They are used in
  141. # dependency statements and link commands. Note that in the case of
  142. # INITObjects, the order of the objects is important. When we install the
  143. # patch into the System heap, we install everything from the first routine
  144. # in INIT.a.o to the end of the resource. This means that everything we
  145. # want to stay resident must be AFTER INIT.a.o, and everything that is not
  146. # needed after installation should be BEFORE INIT.a.o.
  147. #------------------------------------------------------------------------------
  148.  
  149. CDEVObjects        =    ∂
  150.                     'CDEV.c.o'
  151.  
  152. INITObjects        =    ∂
  153.                     'INITInstall.a.o' ∂
  154.                     'ShowINIT.a.o' ∂
  155.                     'INIT.a.o' ∂
  156.                     'INIT.c.o' ∂
  157.                     'SAGlobals.c.o'
  158.  
  159.  
  160. #------------------------------------------------------------------------------
  161. # These help define the libraries that we want to link with. {CLibs} holds
  162. # the libraries we want to link with under MPW 3.0 or MPW 3.1. Under MPW 3.2
  163. # and later, “CInterface.o” and “CRuntime.o” are merged with “Interface.o” and
  164. # “Runtime.o”. So, under 3.2 and later, we link with the files in {CLibs32}
  165. # instead. Note that we use the library routines defined in PLStringFuncs.h,
  166. # which requires us to include “PasLib.o” in our {CLibs} and {CLibs32}
  167. # variables.
  168. #------------------------------------------------------------------------------
  169.  
  170. PLibs            =    ∂
  171.                     "{Libraries}Runtime.o" ∂
  172.                     "{UtilityFolder}"GestaltGlue.a.o ∂
  173.                     "{Libraries}Interface.o" ∂
  174.                     "{PLibraries}PasLib.o"
  175.  
  176. PLibs32            =    ∂
  177.                     "{Libraries}Runtime.o" ∂
  178.                     "{Libraries}Interface.o" ∂
  179.                     "{PLibraries}PasLib.o"
  180.  
  181. CLibs            =    ∂
  182.                     "{CLibraries}CRuntime.o" ∂
  183.                     "{CLibraries}CInterface.o" ∂
  184.                     "{UtilityFolder}"GestaltGlue.a.o ∂
  185.                     "{Libraries}Interface.o" ∂
  186.                     "{PLibraries}PasLib.o"
  187.  
  188. CLibs32            =    ∂
  189.                     "{Libraries}Runtime.o" ∂
  190.                     "{Libraries}Interface.o" ∂
  191.                     "{PLibraries}PasLib.o"
  192.  
  193.  
  194. #------------------------------------------------------------------------------
  195. # Dependencies for the individual components. These will invoke the
  196. # default build rules listed in Chapter 9 of the MPW 3.0 manual.
  197. #
  198. # The below dependency says that all of the object listed in {CDEVObjects} and
  199. # {INITObjects} are dependent on this makefile and “Common.h”.
  200. #------------------------------------------------------------------------------
  201.  
  202. {CDEVObjects} {INITObjects}    ƒ    {AppName}.make Common.h
  203.  
  204.  
  205. #------------------------------------------------------------------------------
  206. # This is a dummy dependency rule.  This will always be executed.  This dummy
  207. # rule must be the first for {AppName} so that it will be executed first.
  208. # This is necessary to make evaluations that are beyond the scope of
  209. # Make.  These evaluations will be performed by the Shell at execution time,
  210. # and they must execute first because compile and link command lines depend
  211. # on variables set up by these evaluations.  This has the unfortunate side
  212. # effect that Make will always consider {AppName} to be out of date.  It will
  213. # always, at a minimum, execute the commands for the target ShellForce.
  214. #
  215. # Also note that we turn Echo off here. This is turned on if you execute
  216. # your make scripts from the "Build" menu (which almost everyone does). We
  217. # turn it off so that you don't have to see any of the instructions that
  218. # determine library sets, etc. We also won't have to see the commands that
  219. # are being used to invoke the C compiler, etc., which can look pretty
  220. # gnarly if you have lots of command line options.
  221. #------------------------------------------------------------------------------
  222.  
  223. {AppName}            ƒƒ ShellForce
  224.  
  225. # With the above rule, {AppName} will always be out of date with respect to
  226. # the non-existent file ShellForce.  This will force the following commands to
  227. # be executed.
  228. ShellForce            ƒ
  229.     Set Echo 0
  230.     IF "{ShellVersion}" == ""
  231.         ( EVALUATE "`Version`" =~ /MPW Shell≈ ([0-9]+(.[ab0-9]+)+)®1≈/ ) ∑ Dev:Null
  232.         SET ShellVersion "{®1}"
  233.     END
  234.     IF "{ShellVersion}" =~ /3.[01]≈/
  235.         SET AAltOptions "-d MPW31=1"
  236.         SET CAltOptions "-d MPW31=true"
  237.         SET PAltOptions "-d MPW31=TRUE"
  238.         SET CSysObjects "`QUOTE {CLibs}`"
  239.         SET PSysObjects "`QUOTE {PLibs}`"
  240.     ELSE
  241.         SET AAltOptions "-d MPW31=0"
  242.         SET CAltOptions "-d MPW31=false"
  243.         SET PAltOptions "-d MPW31=FALSE"
  244.         SET CSysObjects "`QUOTE {CLibs32}`"
  245.         SET PSysObjects "`QUOTE {PLibs32}`"
  246.     END
  247.  
  248.  
  249. #------------------------------------------------------------------------------
  250. # Build rule that links our application together. If any of our objects 
  251. # changes, or this makefile changes, then we relink.  The dummy prerequisite
  252. # ShellForce must come before any other prerequisites for {AppName}.
  253. #------------------------------------------------------------------------------
  254.  
  255. {AppName}            ƒƒ {CDEVObjects}
  256.     Echo "    Linking:    CDEV"
  257.     Link {CDEVLinkOptions} -o {Targ} {CDEVObjects} {CSysObjects}
  258.     SetFile {Targ} -t cdev -c {Signature} -a B
  259.  
  260. {AppName}            ƒƒ {INITObjects}
  261.     Echo "    Linking:    INIT"
  262.     Link {INITLinkOptions} -o {Targ} {INITObjects} {CSysObjects}
  263.     SetFile {Targ} -t cdev -c {Signature} -a B
  264.  
  265.  
  266. #------------------------------------------------------------------------------
  267. # Build rule that creates our resources and adds them to the application
  268. #------------------------------------------------------------------------------
  269.  
  270. {AppName}        ƒƒ    {AppName}.make ∂
  271.                     'CDEV.rsrc'
  272.     Echo "    Merging:    CDEV.rsrc"
  273.     Echo 'include "CDEV.rsrc";' | Rez {RezOptions} -o {AppName}
  274.  
  275. #------------------------------------------------------------------------------
  276. # Build rule that copies our CDEV to the System Folder when it's all built.
  277. #------------------------------------------------------------------------------
  278.  
  279. #{AppName}        ƒƒ    {CDEVObjects} {INITObjects} 'CDEV.rsrc' {AppName}.make
  280. #    Duplicate -y {AppName} "{SystemFolder}"
  281.